/*
 * @Description: 对象的自定义字段
 * @Author: june
 */
import request from "@/utils/request";

// 新增
export function subjectCustomFieldSave(subjectCustomFieldAddDTO) {
  return request({
    url: "/config/api/v1/subjectCustomFields",
    method: "post",
    data: subjectCustomFieldAddDTO
  });
}

// 修改
export function subjectCustomFieldUpdate(subjectCustomFieldUpdateDTO) {
  return request({
    url: "/config/api/v1/subjectCustomFields",
    method: "put",
    data: subjectCustomFieldUpdateDTO
  });
}

// 单个删除
export function subjectCustomFieldDelete(subjectCustomFieldId) {
  return request({
    url: `/config/api/v1/subjectCustomFields/${subjectCustomFieldId}`,
    method: "delete"
  });
}

// 批量删除
export function subjectCustomFieldDeleteBatch(subjectCustomFieldIds) {
  return request({
    url: "/config/api/v1/subjectCustomFields",
    method: "delete",
    data: subjectCustomFieldIds
  });
}

// 根据id查找
export function subjectCustomFieldFindById(subjectCustomFieldId) {
  return request({
    url: `/config/api/v1/subjectCustomFields/${subjectCustomFieldId}`,
    method: "get"
  });
}

// 查找所有
export function subjectCustomFieldListAll(subjectCustomFieldQuery) {
  return request({
    url: "/config/api/v1/subjectCustomFields/listAll",
    method: "get",
    params: subjectCustomFieldQuery
  });
}

// 分页查询
export function subjectCustomFieldPage(subjectCustomFieldQuery) {
  let ordersParam = "";
  if (subjectCustomFieldQuery.orders) {
    subjectCustomFieldQuery.orders.forEach((order, index) => {
      const op = "orders[" + index + "]";
      if (ordersParam !== "") {
        ordersParam += "&";
      }
      ordersParam += op + ".property=" + order.property + "&" + op + ".desc=" + order.desc;
    });
    subjectCustomFieldQuery.orders = undefined;
  }
  return request({
    url: "/config/api/v1/subjectCustomFields?" + ordersParam,
    method: "get",
    params: subjectCustomFieldQuery
  });
}
